package controllers;

import java.io.IOException;

import ccrm.ClientMain;
import entitys.Category;
import entitys.MarketingPattern;
import entitys.Product;
import entitys.Request;
import entitys.Session;
import entitys.Type;
import enums.Command;
import enums.Result;

public class SetMarketingPattersController {

	
	public static void getProducts()
	{
		
		//Request r =new Request(Command.GET_PRODUCTS,"123",sector +"@"+type);
		Request r =new Request(Command.GET_PRODUCTS,Session.getEmployee().getUserId());
		
		try {
			ClientMain.client.sendToServer(r);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
	}
	
	public static void getProducts(int type,int sector)
	{
		String s = new String(sector+"@"+type);
		
		Request r =new Request(Command.GET_PRODUCTS,Session.getEmployee().getUserId(),s);
		//Request r =new Request(Command.GET_PRODUCTS,"123");
		
		try {
			ClientMain.client.sendToServer(r);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
	}
	
	
	public static void getType() {
		// TODO Auto-generated method stub
		Request r =new Request(Command.GET_PRODUCT_TYPES,Session.getEmployee().getUserId());
		
		try {
			ClientMain.client.sendToServer(r);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	public static void getCategory() {
		// TODO Auto-generated method stub
		Request r =new Request(Command.GET_PRODUCT_CATEGORIES,Session.getEmployee().getUserId());
		
		try {
			ClientMain.client.sendToServer(r);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	
	public static Result setMarketingPattern(int productID,int fromAge,int toAge,String areas,int significance,int interestLevel,int marketingAccess,String MessageToClient)
	{
		Request r =new Request(Command.ADD_MARKETING_PATTERN,Session.getEmployee().getUserId(),new MarketingPattern(productID,fromAge,toAge,areas,significance,interestLevel,marketingAccess,MessageToClient));

		try {
			ClientMain.client.sendToServer(r);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
		return Result.OK;	
	}

	public static void getType(int category) {
		// TODO Auto-generated method stub
		Request r =new Request(Command.GET_PRODUCT_TYPES_BY_CATEGORY,Session.getEmployee().getUserId(), new Category("",category));
		
		try {
			ClientMain.client.sendToServer(r);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	
	
}
